/*
 * File Name: MessageFactory.h
 *
 * Created on: 2021-01-28
 * Author: glendy ganby@163.com
 *
 * Last Modified: 2021-01-28
 * Description:
 */

#ifndef _MESSAGEFACTORY_H_
#define _MESSAGEFACTORY_H_

#include <string>
#include <map>

namespace miniproto
{
class Message;

class MessageFactory
{
public:
	typedef std::map<std::string, ::miniproto::Message *> MsgTypeMap;
public:
	MessageFactory();
	~MessageFactory();

	void init();
	virtual void init_msg_map() = 0;

	void register_message(const ::std::string &type_name, ::miniproto::Message *obj);
	::miniproto::Message *create(const ::std::string &type_name) const;

protected:
	MsgTypeMap *msg_map_;
};

} // namespace miniproto

#endif //_MESSAGEFACTORY_H_
